var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var session = require('express-session');
var mysql = require('mysql');
var logger = require('morgan');
var user = require('./routes/user');
var product = require("./routes/product");
var cart = require("./routes/cart");
var order = require("./routes/order");
var address = require("./routes/address");
var app = express();

app.use(session({
    secret: 'itcast-secret',
    name: 'itcast-name',
    cookie: { maxAge: 8000000000 },
    resave: false,
    saveUninitialized: true
}));

//日志
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));

app.use('/cart', cart);
app.use('/order', order);
app.use('/user', user);
app.use('/product', product);
app.use('/address', address);


module.exports = app;